feat(menubar): expose combined multi-device usage in menubar-json (#566)#567
Merged
iamtoruk merged 2 commits intoJun 28, 2026
Merged
Conversation
…tagentseal#566) The macOS menubar reads `codeburn status --format menubar-json`, which only ever reflected the local machine. Multi-device "Combined" usage existed only in the terminal `devices` command. This exposes combined + per-device usage through the menubar-json contract so the menubar can mirror the combined dashboard. - Extract the per-device summary + combined reduce that was inline in renderDevices into a reusable pure `summarizeDeviceUsage(results, window?)`. Error/unreachable devices are excluded from the combined sums (kept in perDevice); deviceCount counts all, reachableCount counts the reachable ones. renderDevices now formats from it with byte-identical output. - Add an optional `combined?: CombinedUsage` block to MenubarPayload (perDevice list + combined totals incl. calls/sessions). Absent by default. - Add `--scope local|combined` to `status` (default local). `combined` builds the local payload, pulls paired devices (pullDevices isolates per-peer failures), and attaches the summary. - Correctness guards: reject `--scope combined` with `--days` (non-contiguous, not representable over the sharing query) and with `--provider`/`--project`/ `--exclude` (the sharing query carries no filters, so peers would report unfiltered usage). Window-scope the cache-token sum to the selected period (cache lives in 365-day daily history; current carries no cache counts). TS/CLI only. The menubar Local/Combined toggle + render is a follow-up.
Contributor
Author
|
@iamtoruk I think you might be interested in these, I think you are eligible. |
Member
|
@ozymandiashh For Anthropic, we have already been selected, and I am in their OSS program. For OpenAI, I have applied. Let's see. |
Contributor
Author
|
congrats |
The status --format menubar-json --scope combined path pulls paired devices. Wrap that best-effort enrichment in a guard so an unexpected failure (corrupt remotes store, peer I/O) can never take down the base local menubar payload — on error the local payload is still emitted with combined omitted. Add a test that a corrupt remote-devices.json still yields a valid combined (local-only) payload.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Addresses #566 (data layer). The macOS menubar reads
codeburn status --format menubar-json, which only reflects the local machine. Combined multi-device usage existed only in the terminalcodeburn devicescommand. This exposes combined + per-device usage through the menubar-json contract so the menubar can mirror the combined dashboard. The menubar UI toggle itself is a follow-up Swift PR.What changed
renderDevices(src/sharing/host.ts) into a reusable puresummarizeDeviceUsage(results, window?).renderDevicesnow formats from it with byte-identical output (existing tests unchanged). Error/unreachable devices are excluded from the combined sums but kept inperDevice;deviceCountcounts all,reachableCountcounts those that responded.combined?: CombinedUsageonMenubarPayload(per-device list + combined totals incl. calls/sessions). Absent by default, so existing consumers are unaffected.--scope local|combinedonstatus(defaultlocal).combinedbuilds the local payload, pulls paired devices viapullDevices(per-peer failures isolated into error rows, never block), and attaches the summary.--scope combinedwith--days(non-contiguous, not representable over the sharingUsageQuery) and with--provider/--project/--exclude(the sharing query carries no filters, so peers would report unfiltered usage). Window-scope the combined cache-token sum to the selected period (cache lives in the 365-day daily history;currentcarries no cache counts).Testing
npx vitest run tests/sharing/host.test.ts tests/menubar-json.test.ts tests/cli-status-menubar.test.ts-> 28/28. New cases:summarizeDeviceUsagecombined totals + error-row exclusion + window-scoped cache;MenubarPayloadomitscombinedby default and accepts the documented shape; CLI attachescombinedfor--scope combined(and omits it for local); CLI rejects--scope combinedwith--days/--provider/--project/--exclude.npx tsc --noEmitclean; semgrep hot-path rule -> 0 findings.overview.test.tsthousands-separator case, which fails on non-US locales independent of this change (reproduces onmain).Notes